{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "%load_ext autoreload\n",
    "%autoreload 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import h1st.core as h1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<!-- Generated by graphviz version 2.42.3 (20191010.1750)\n -->\n<!-- Title: %3 Pages: 1 -->\n<svg width=\"208pt\" height=\"46pt\"\n viewBox=\"0.00 0.00 208.01 46.01\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 42.01)\">\n<title>%3</title>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-42.01 204.01,-42.01 204.01,4 -4,4\"/>\n<!-- Action\n 140657497977360 -->\n<g id=\"node1\" class=\"node\">\n<title>Action\n 140657497977360</title>\n<ellipse fill=\"#7890ac\" stroke=\"#7890ac\" cx=\"19\" cy=\"-19\" rx=\"19.01\" ry=\"19.01\"/>\n<text text-anchor=\"middle\" x=\"19\" y=\"-16.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">start</text>\n</g>\n<!-- Action\n 140657497977680 -->\n<g id=\"node2\" class=\"node\">\n<title>Action\n 140657497977680</title>\n<path fill=\"#7890ac\" stroke=\"#7890ac\" d=\"M116.01,-37C116.01,-37 86.01,-37 86.01,-37 80.01,-37 74.01,-31 74.01,-25 74.01,-25 74.01,-13 74.01,-13 74.01,-7 80.01,-1 86.01,-1 86.01,-1 116.01,-1 116.01,-1 122.01,-1 128.01,-7 128.01,-13 128.01,-13 128.01,-25 128.01,-25 128.01,-31 122.01,-37 116.01,-37\"/>\n<text text-anchor=\"middle\" x=\"101.01\" y=\"-16.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">node1</text>\n</g>\n<!-- Action\n 140657497977360&#45;&gt;Action\n 140657497977680 -->\n<g id=\"edge1\" class=\"edge\">\n<title>Action\n 140657497977360&#45;&gt;Action\n 140657497977680</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M38.02,-19C38.02,-19 68.7,-19 68.7,-19\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"68.7,-20.75 73.7,-19 68.7,-17.25 68.7,-20.75\"/>\n</g>\n<!-- Action\n 140657497977616 -->\n<g id=\"node3\" class=\"node\">\n<title>Action\n 140657497977616</title>\n<ellipse fill=\"#7890ac\" stroke=\"#7890ac\" cx=\"182.01\" cy=\"-19\" rx=\"18\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"182.01\" y=\"-16.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">end</text>\n</g>\n<!-- Action\n 140657497977680&#45;&gt;Action\n 140657497977616 -->\n<g id=\"edge2\" class=\"edge\">\n<title>Action\n 140657497977680&#45;&gt;Action\n 140657497977616</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M128.43,-19C128.43,-19 158.54,-19 158.54,-19\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"158.54,-20.75 163.54,-19 158.54,-17.25 158.54,-20.75\"/>\n</g>\n</g>\n</svg>\n",
      "text/plain": [
       "<hfai.core.viz.DotGraphVisualizer at 0x7fed6033b450>"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "g = h1.Graph()\n",
    "g.start()\n",
    "g.add(h1.Model(), id='node1')\n",
    "g.end()\n",
    "\n",
    "g.visualize()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<!-- Generated by graphviz version 2.42.3 (20191010.1750)\n -->\n<!-- Title: %3 Pages: 1 -->\n<svg width=\"298pt\" height=\"46pt\"\n viewBox=\"0.00 0.00 298.01 46.01\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 42.01)\">\n<title>%3</title>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-42.01 294.01,-42.01 294.01,4 -4,4\"/>\n<!-- Action\n 140657503166800 -->\n<g id=\"node1\" class=\"node\">\n<title>Action\n 140657503166800</title>\n<ellipse fill=\"#7890ac\" stroke=\"#7890ac\" cx=\"19\" cy=\"-19\" rx=\"19.01\" ry=\"19.01\"/>\n<text text-anchor=\"middle\" x=\"19\" y=\"-16.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">start</text>\n</g>\n<!-- Action\n 140657503167120 -->\n<g id=\"node2\" class=\"node\">\n<title>Action\n 140657503167120</title>\n<path fill=\"#7890ac\" stroke=\"#7890ac\" d=\"M116.01,-37C116.01,-37 86.01,-37 86.01,-37 80.01,-37 74.01,-31 74.01,-25 74.01,-25 74.01,-13 74.01,-13 74.01,-7 80.01,-1 86.01,-1 86.01,-1 116.01,-1 116.01,-1 122.01,-1 128.01,-7 128.01,-13 128.01,-13 128.01,-25 128.01,-25 128.01,-31 122.01,-37 116.01,-37\"/>\n<text text-anchor=\"middle\" x=\"101.01\" y=\"-16.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">node1</text>\n</g>\n<!-- Action\n 140657503166800&#45;&gt;Action\n 140657503167120 -->\n<g id=\"edge1\" class=\"edge\">\n<title>Action\n 140657503166800&#45;&gt;Action\n 140657503167120</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M38.02,-19C38.02,-19 68.7,-19 68.7,-19\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"68.7,-20.75 73.7,-19 68.7,-17.25 68.7,-20.75\"/>\n</g>\n<!-- Action\n 140657503167248 -->\n<g id=\"node3\" class=\"node\">\n<title>Action\n 140657503167248</title>\n<path fill=\"#7890ac\" stroke=\"#7890ac\" d=\"M206.01,-37C206.01,-37 176.01,-37 176.01,-37 170.01,-37 164.01,-31 164.01,-25 164.01,-25 164.01,-13 164.01,-13 164.01,-7 170.01,-1 176.01,-1 176.01,-1 206.01,-1 206.01,-1 212.01,-1 218.01,-7 218.01,-13 218.01,-13 218.01,-25 218.01,-25 218.01,-31 212.01,-37 206.01,-37\"/>\n<text text-anchor=\"middle\" x=\"191.01\" y=\"-16.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">node2</text>\n</g>\n<!-- Action\n 140657503167120&#45;&gt;Action\n 140657503167248 -->\n<g id=\"edge2\" class=\"edge\">\n<title>Action\n 140657503167120&#45;&gt;Action\n 140657503167248</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M128.01,-19C128.01,-19 158.71,-19 158.71,-19\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"158.71,-20.75 163.71,-19 158.71,-17.25 158.71,-20.75\"/>\n</g>\n<!-- Action\n 140657503167376 -->\n<g id=\"node4\" class=\"node\">\n<title>Action\n 140657503167376</title>\n<ellipse fill=\"#7890ac\" stroke=\"#7890ac\" cx=\"272.01\" cy=\"-19\" rx=\"18\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"272.01\" y=\"-16.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">end</text>\n</g>\n<!-- Action\n 140657503167248&#45;&gt;Action\n 140657503167376 -->\n<g id=\"edge3\" class=\"edge\">\n<title>Action\n 140657503167248&#45;&gt;Action\n 140657503167376</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M218.43,-19C218.43,-19 248.54,-19 248.54,-19\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"248.54,-20.75 253.54,-19 248.54,-17.25 248.54,-20.75\"/>\n</g>\n</g>\n</svg>\n",
      "text/plain": [
       "<hfai.core.viz.DotGraphVisualizer at 0x7fed60817310>"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "g = h1.Graph()\n",
    "g.start()\n",
    "g.add(h1.Model(), id='node1')\n",
    "g.add(h1.Model(), id='node2')\n",
    "g.end()\n",
    "\n",
    "g.visualize()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Warning: Orthogonal edges do not currently handle edge labels. Try using xlabels.\n"
     ]
    },
    {
     "data": {
      "image/svg+xml": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<!-- Generated by graphviz version 2.42.3 (20191010.1750)\n -->\n<!-- Title: %3 Pages: 1 -->\n<svg width=\"438pt\" height=\"98pt\"\n viewBox=\"0.00 0.00 437.69 98.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 94)\">\n<title>%3</title>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-94 433.69,-94 433.69,4 -4,4\"/>\n<!-- Action\n 140657511860688 -->\n<g id=\"node1\" class=\"node\">\n<title>Action\n 140657511860688</title>\n<ellipse fill=\"#7890ac\" stroke=\"#7890ac\" cx=\"19\" cy=\"-45\" rx=\"19.01\" ry=\"19.01\"/>\n<text text-anchor=\"middle\" x=\"19\" y=\"-42.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">start</text>\n</g>\n<!-- Action\n 140657511860368 -->\n<g id=\"node2\" class=\"node\">\n<title>Action\n 140657511860368</title>\n<path fill=\"#7890ac\" stroke=\"#7890ac\" d=\"M117.01,-63C117.01,-63 87.01,-63 87.01,-63 81.01,-63 75.01,-57 75.01,-51 75.01,-51 75.01,-39 75.01,-39 75.01,-33 81.01,-27 87.01,-27 87.01,-27 117.01,-27 117.01,-27 123.01,-27 129.01,-33 129.01,-39 129.01,-39 129.01,-51 129.01,-51 129.01,-57 123.01,-63 117.01,-63\"/>\n<text text-anchor=\"middle\" x=\"102.01\" y=\"-42.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">node1</text>\n</g>\n<!-- Action\n 140657511860688&#45;&gt;Action\n 140657511860368 -->\n<g id=\"edge1\" class=\"edge\">\n<title>Action\n 140657511860688&#45;&gt;Action\n 140657511860368</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M38.26,-45C38.26,-45 70,-45 70,-45\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"70,-46.75 75,-45 70,-43.25 70,-46.75\"/>\n</g>\n<!-- Decision\n 140657511860496 -->\n<g id=\"node3\" class=\"node\">\n<title>Decision\n 140657511860496</title>\n<polygon fill=\"#7890ac\" stroke=\"#7890ac\" points=\"209.35,-63 166.17,-45 209.35,-27 252.52,-45 209.35,-63\"/>\n<text text-anchor=\"middle\" x=\"209.35\" y=\"-42.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">decision1</text>\n</g>\n<!-- Action\n 140657511860368&#45;&gt;Decision\n 140657511860496 -->\n<g id=\"edge2\" class=\"edge\">\n<title>Action\n 140657511860368&#45;&gt;Decision\n 140657511860496</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M129.09,-45C129.09,-45 160.98,-45 160.98,-45\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"160.98,-46.75 165.98,-45 160.98,-43.25 160.98,-46.75\"/>\n</g>\n<!-- Action\n 140657511859920 -->\n<g id=\"node4\" class=\"node\">\n<title>Action\n 140657511859920</title>\n<path fill=\"#7890ac\" stroke=\"#7890ac\" d=\"M344.69,-90C344.69,-90 314.69,-90 314.69,-90 308.69,-90 302.69,-84 302.69,-78 302.69,-78 302.69,-66 302.69,-66 302.69,-60 308.69,-54 314.69,-54 314.69,-54 344.69,-54 344.69,-54 350.69,-54 356.69,-60 356.69,-66 356.69,-66 356.69,-78 356.69,-78 356.69,-84 350.69,-90 344.69,-90\"/>\n<text text-anchor=\"middle\" x=\"329.69\" y=\"-69.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">yes</text>\n</g>\n<!-- Decision\n 140657511860496&#45;&gt;Action\n 140657511859920 -->\n<g id=\"edge3\" class=\"edge\">\n<title>Decision\n 140657511860496&#45;&gt;Action\n 140657511859920</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M220.45,-58.5C220.45,-58.5 297.5,-58.5 297.5,-58.5\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"297.5,-60.25 302.5,-58.5 297.5,-56.75 297.5,-60.25\"/>\n<text text-anchor=\"middle\" x=\"277.69\" y=\"-67.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">yes</text>\n</g>\n<!-- Action\n 140657511858960 -->\n<g id=\"node5\" class=\"node\">\n<title>Action\n 140657511858960</title>\n<path fill=\"#7890ac\" stroke=\"#7890ac\" d=\"M344.69,-36C344.69,-36 314.69,-36 314.69,-36 308.69,-36 302.69,-30 302.69,-24 302.69,-24 302.69,-12 302.69,-12 302.69,-6 308.69,0 314.69,0 314.69,0 344.69,0 344.69,0 350.69,0 356.69,-6 356.69,-12 356.69,-12 356.69,-24 356.69,-24 356.69,-30 350.69,-36 344.69,-36\"/>\n<text text-anchor=\"middle\" x=\"329.69\" y=\"-15.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">no</text>\n</g>\n<!-- Decision\n 140657511860496&#45;&gt;Action\n 140657511858960 -->\n<g id=\"edge4\" class=\"edge\">\n<title>Decision\n 140657511860496&#45;&gt;Action\n 140657511858960</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M220.45,-31.5C220.45,-31.5 297.5,-31.5 297.5,-31.5\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"297.5,-33.25 302.5,-31.5 297.5,-29.75 297.5,-33.25\"/>\n<text text-anchor=\"middle\" x=\"277.69\" y=\"-30.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">no</text>\n</g>\n<!-- Action\n 140657511860112 -->\n<g id=\"node6\" class=\"node\">\n<title>Action\n 140657511860112</title>\n<ellipse fill=\"#7890ac\" stroke=\"#7890ac\" cx=\"411.69\" cy=\"-44\" rx=\"18\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"411.69\" y=\"-41.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">end</text>\n</g>\n<!-- Action\n 140657511859920&#45;&gt;Action\n 140657511860112 -->\n<g id=\"edge5\" class=\"edge\">\n<title>Action\n 140657511859920&#45;&gt;Action\n 140657511860112</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M357,-58C357,-58 395.25,-58 395.25,-58\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"395.25,-59.75 400.25,-58 395.25,-56.25 395.25,-59.75\"/>\n</g>\n<!-- Action\n 140657511858960&#45;&gt;Action\n 140657511860112 -->\n<g id=\"edge6\" class=\"edge\">\n<title>Action\n 140657511858960&#45;&gt;Action\n 140657511860112</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M357,-31C357,-31 393.96,-31 393.96,-31\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"393.96,-32.75 398.96,-31 393.96,-29.25 393.96,-32.75\"/>\n</g>\n</g>\n</svg>\n",
      "text/plain": [
       "<hfai.core.viz.DotGraphVisualizer at 0x7fed6080b490>"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "g = h1.Graph()\n",
    "g.start()\n",
    "g.add(h1.Model(), id='node1')\n",
    "g.add(h1.Decision(h1.Model(), id='decision1'))\\\n",
    "    .add(yes=h1.Action(h1.Model(), id='yes'), no=h1.Action(h1.Model(), id='no'))\n",
    "g.end()\n",
    "\n",
    "g.visualize()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Warning: Orthogonal edges do not currently handle edge labels. Try using xlabels.\n"
     ]
    },
    {
     "data": {
      "image/svg+xml": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<!-- Generated by graphviz version 2.42.3 (20191010.1750)\n -->\n<!-- Title: %3 Pages: 1 -->\n<svg width=\"540pt\" height=\"98pt\"\n viewBox=\"0.00 0.00 539.73 98.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 94)\">\n<title>%3</title>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-94 535.73,-94 535.73,4 -4,4\"/>\n<!-- Action\n 140657495704976 -->\n<g id=\"node1\" class=\"node\">\n<title>Action\n 140657495704976</title>\n<ellipse fill=\"#7890ac\" stroke=\"#7890ac\" cx=\"19\" cy=\"-45\" rx=\"19.01\" ry=\"19.01\"/>\n<text text-anchor=\"middle\" x=\"19\" y=\"-42.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">start</text>\n</g>\n<!-- Action\n 140657494280016 -->\n<g id=\"node2\" class=\"node\">\n<title>Action\n 140657494280016</title>\n<path fill=\"#7890ac\" stroke=\"#7890ac\" d=\"M117.01,-63C117.01,-63 87.01,-63 87.01,-63 81.01,-63 75.01,-57 75.01,-51 75.01,-51 75.01,-39 75.01,-39 75.01,-33 81.01,-27 87.01,-27 87.01,-27 117.01,-27 117.01,-27 123.01,-27 129.01,-33 129.01,-39 129.01,-39 129.01,-51 129.01,-51 129.01,-57 123.01,-63 117.01,-63\"/>\n<text text-anchor=\"middle\" x=\"102.01\" y=\"-42.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">node1</text>\n</g>\n<!-- Action\n 140657495704976&#45;&gt;Action\n 140657494280016 -->\n<g id=\"edge1\" class=\"edge\">\n<title>Action\n 140657495704976&#45;&gt;Action\n 140657494280016</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M38.26,-45C38.26,-45 70,-45 70,-45\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"70,-46.75 75,-45 70,-43.25 70,-46.75\"/>\n</g>\n<!-- Decision\n 140657494279696 -->\n<g id=\"node3\" class=\"node\">\n<title>Decision\n 140657494279696</title>\n<polygon fill=\"#7890ac\" stroke=\"#7890ac\" points=\"209.35,-63 166.17,-45 209.35,-27 252.52,-45 209.35,-63\"/>\n<text text-anchor=\"middle\" x=\"209.35\" y=\"-42.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">decision1</text>\n</g>\n<!-- Action\n 140657494280016&#45;&gt;Decision\n 140657494279696 -->\n<g id=\"edge2\" class=\"edge\">\n<title>Action\n 140657494280016&#45;&gt;Decision\n 140657494279696</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M129.09,-45C129.09,-45 160.98,-45 160.98,-45\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"160.98,-46.75 165.98,-45 160.98,-43.25 160.98,-46.75\"/>\n</g>\n<!-- Action\n 140657494279568 -->\n<g id=\"node4\" class=\"node\">\n<title>Action\n 140657494279568</title>\n<path fill=\"#7890ac\" stroke=\"#7890ac\" d=\"M344.69,-90C344.69,-90 314.69,-90 314.69,-90 308.69,-90 302.69,-84 302.69,-78 302.69,-78 302.69,-66 302.69,-66 302.69,-60 308.69,-54 314.69,-54 314.69,-54 344.69,-54 344.69,-54 350.69,-54 356.69,-60 356.69,-66 356.69,-66 356.69,-78 356.69,-78 356.69,-84 350.69,-90 344.69,-90\"/>\n<text text-anchor=\"middle\" x=\"329.69\" y=\"-69.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">yes1</text>\n</g>\n<!-- Decision\n 140657494279696&#45;&gt;Action\n 140657494279568 -->\n<g id=\"edge3\" class=\"edge\">\n<title>Decision\n 140657494279696&#45;&gt;Action\n 140657494279568</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M220.45,-58.5C220.45,-58.5 297.5,-58.5 297.5,-58.5\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"297.5,-60.25 302.5,-58.5 297.5,-56.75 297.5,-60.25\"/>\n<text text-anchor=\"middle\" x=\"277.69\" y=\"-67.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">yes</text>\n</g>\n<!-- Action\n 140657494279120 -->\n<g id=\"node5\" class=\"node\">\n<title>Action\n 140657494279120</title>\n<path fill=\"#7890ac\" stroke=\"#7890ac\" d=\"M344.69,-36C344.69,-36 314.69,-36 314.69,-36 308.69,-36 302.69,-30 302.69,-24 302.69,-24 302.69,-12 302.69,-12 302.69,-6 308.69,0 314.69,0 314.69,0 344.69,0 344.69,0 350.69,0 356.69,-6 356.69,-12 356.69,-12 356.69,-24 356.69,-24 356.69,-30 350.69,-36 344.69,-36\"/>\n<text text-anchor=\"middle\" x=\"329.69\" y=\"-15.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">no1</text>\n</g>\n<!-- Decision\n 140657494279696&#45;&gt;Action\n 140657494279120 -->\n<g id=\"edge4\" class=\"edge\">\n<title>Decision\n 140657494279696&#45;&gt;Action\n 140657494279120</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M220.45,-31.5C220.45,-31.5 297.5,-31.5 297.5,-31.5\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"297.5,-33.25 302.5,-31.5 297.5,-29.75 297.5,-33.25\"/>\n<text text-anchor=\"middle\" x=\"277.69\" y=\"-30.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">no</text>\n</g>\n<!-- Action\n 140657494383120 -->\n<g id=\"node6\" class=\"node\">\n<title>Action\n 140657494383120</title>\n<path fill=\"#7890ac\" stroke=\"#7890ac\" d=\"M446.76,-90C446.76,-90 405.67,-90 405.67,-90 399.67,-90 393.67,-84 393.67,-78 393.67,-78 393.67,-66 393.67,-66 393.67,-60 399.67,-54 405.67,-54 405.67,-54 446.76,-54 446.76,-54 452.76,-54 458.76,-60 458.76,-66 458.76,-66 458.76,-78 458.76,-78 458.76,-84 452.76,-90 446.76,-90\"/>\n<text text-anchor=\"middle\" x=\"426.21\" y=\"-69.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">yes1_node1</text>\n</g>\n<!-- Action\n 140657494279568&#45;&gt;Action\n 140657494383120 -->\n<g id=\"edge5\" class=\"edge\">\n<title>Action\n 140657494279568&#45;&gt;Action\n 140657494383120</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M356.83,-72C356.83,-72 388.45,-72 388.45,-72\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"388.45,-73.75 393.45,-72 388.45,-70.25 388.45,-73.75\"/>\n</g>\n<!-- Action\n 140657494277840 -->\n<g id=\"node7\" class=\"node\">\n<title>Action\n 140657494277840</title>\n<path fill=\"#7890ac\" stroke=\"#7890ac\" d=\"M444.76,-36C444.76,-36 407.66,-36 407.66,-36 401.66,-36 395.66,-30 395.66,-24 395.66,-24 395.66,-12 395.66,-12 395.66,-6 401.66,0 407.66,0 407.66,0 444.76,0 444.76,0 450.76,0 456.76,-6 456.76,-12 456.76,-12 456.76,-24 456.76,-24 456.76,-30 450.76,-36 444.76,-36\"/>\n<text text-anchor=\"middle\" x=\"426.21\" y=\"-15.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">no1_node2</text>\n</g>\n<!-- Action\n 140657494279120&#45;&gt;Action\n 140657494277840 -->\n<g id=\"edge6\" class=\"edge\">\n<title>Action\n 140657494279120&#45;&gt;Action\n 140657494277840</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M356.83,-18C356.83,-18 390.54,-18 390.54,-18\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"390.54,-19.75 395.54,-18 390.54,-16.25 390.54,-19.75\"/>\n</g>\n<!-- Action\n 140657494278032 -->\n<g id=\"node8\" class=\"node\">\n<title>Action\n 140657494278032</title>\n<ellipse fill=\"#7890ac\" stroke=\"#7890ac\" cx=\"513.73\" cy=\"-44\" rx=\"18\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"513.73\" y=\"-41.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">end</text>\n</g>\n<!-- Action\n 140657494383120&#45;&gt;Action\n 140657494278032 -->\n<g id=\"edge7\" class=\"edge\">\n<title>Action\n 140657494383120&#45;&gt;Action\n 140657494278032</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M458.8,-58C458.8,-58 497.08,-58 497.08,-58\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"497.08,-59.75 502.08,-58 497.08,-56.25 497.08,-59.75\"/>\n</g>\n<!-- Action\n 140657494277840&#45;&gt;Action\n 140657494278032 -->\n<g id=\"edge8\" class=\"edge\">\n<title>Action\n 140657494277840&#45;&gt;Action\n 140657494278032</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M456.82,-31C456.82,-31 496.06,-31 496.06,-31\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"496.06,-32.75 501.06,-31 496.06,-29.25 496.06,-32.75\"/>\n</g>\n</g>\n</svg>\n",
      "text/plain": [
       "<hfai.core.viz.DotGraphVisualizer at 0x7fed6082e450>"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "g = h1.Graph()\n",
    "g.start()\n",
    "g.add(h1.Model(), id='node1')\n",
    "yes1, no1 = g.add(h1.Decision(h1.Model(), id='decision1'))\\\n",
    "    .add(yes=h1.Action(hf.Model(), id='yes1'), no=h1.Action(h1.Model(), id='no1'))\n",
    "\n",
    "yes1.add(h1.Model(), id='yes1_node1')\n",
    "no1.add(h1.Model(), id='no1_node2')\n",
    "\n",
    "g.end()\n",
    "\n",
    "g.visualize()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Warning: Orthogonal edges do not currently handle edge labels. Try using xlabels.\n"
     ]
    },
    {
     "data": {
      "image/svg+xml": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<!-- Generated by graphviz version 2.42.3 (20191010.1750)\n -->\n<!-- Title: %3 Pages: 1 -->\n<svg width=\"625pt\" height=\"144pt\"\n viewBox=\"0.00 0.00 625.41 144.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 140)\">\n<title>%3</title>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-140 621.41,-140 621.41,4 -4,4\"/>\n<!-- Action\n 140721995961808 -->\n<g id=\"node1\" class=\"node\">\n<title>Action\n 140721995961808</title>\n<ellipse fill=\"#7890ac\" stroke=\"#7890ac\" cx=\"19\" cy=\"-91\" rx=\"19.01\" ry=\"19.01\"/>\n<text text-anchor=\"middle\" x=\"19\" y=\"-88.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">start</text>\n</g>\n<!-- Decision\n 140721995962832 -->\n<g id=\"node2\" class=\"node\">\n<title>Decision\n 140721995962832</title>\n<polygon fill=\"#7890ac\" stroke=\"#7890ac\" points=\"118.35,-109 75.17,-91 118.35,-73 161.52,-91 118.35,-109\"/>\n<text text-anchor=\"middle\" x=\"118.35\" y=\"-88.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">decision1</text>\n</g>\n<!-- Action\n 140721995961808&#45;&gt;Decision\n 140721995962832 -->\n<g id=\"edge1\" class=\"edge\">\n<title>Action\n 140721995961808&#45;&gt;Decision\n 140721995962832</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M38.16,-91C38.16,-91 69.97,-91 69.97,-91\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"69.97,-92.75 74.97,-91 69.97,-89.25 69.97,-92.75\"/>\n</g>\n<!-- Action\n 140721992893968 -->\n<g id=\"node3\" class=\"node\">\n<title>Action\n 140721992893968</title>\n<path fill=\"#7890ac\" stroke=\"#7890ac\" d=\"M253.69,-136C253.69,-136 223.69,-136 223.69,-136 217.69,-136 211.69,-130 211.69,-124 211.69,-124 211.69,-112 211.69,-112 211.69,-106 217.69,-100 223.69,-100 223.69,-100 253.69,-100 253.69,-100 259.69,-100 265.69,-106 265.69,-112 265.69,-112 265.69,-124 265.69,-124 265.69,-130 259.69,-136 253.69,-136\"/>\n<text text-anchor=\"middle\" x=\"238.69\" y=\"-115.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">yes1</text>\n</g>\n<!-- Decision\n 140721995962832&#45;&gt;Action\n 140721992893968 -->\n<g id=\"edge2\" class=\"edge\">\n<title>Decision\n 140721995962832&#45;&gt;Action\n 140721992893968</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M129.45,-104.5C129.45,-104.5 206.5,-104.5 206.5,-104.5\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"206.5,-106.25 211.5,-104.5 206.5,-102.75 206.5,-106.25\"/>\n<text text-anchor=\"middle\" x=\"186.69\" y=\"-113.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">yes</text>\n</g>\n<!-- Action\n 140721992893392 -->\n<g id=\"node4\" class=\"node\">\n<title>Action\n 140721992893392</title>\n<path fill=\"#7890ac\" stroke=\"#7890ac\" d=\"M253.69,-82C253.69,-82 223.69,-82 223.69,-82 217.69,-82 211.69,-76 211.69,-70 211.69,-70 211.69,-58 211.69,-58 211.69,-52 217.69,-46 223.69,-46 223.69,-46 253.69,-46 253.69,-46 259.69,-46 265.69,-52 265.69,-58 265.69,-58 265.69,-70 265.69,-70 265.69,-76 259.69,-82 253.69,-82\"/>\n<text text-anchor=\"middle\" x=\"238.69\" y=\"-61.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">no1</text>\n</g>\n<!-- Decision\n 140721995962832&#45;&gt;Action\n 140721992893392 -->\n<g id=\"edge3\" class=\"edge\">\n<title>Decision\n 140721995962832&#45;&gt;Action\n 140721992893392</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M129.45,-77.5C129.45,-77.5 206.5,-77.5 206.5,-77.5\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"206.5,-79.25 211.5,-77.5 206.5,-75.75 206.5,-79.25\"/>\n<text text-anchor=\"middle\" x=\"186.69\" y=\"-76.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">no</text>\n</g>\n<!-- Action\n 140721994062480 -->\n<g id=\"node5\" class=\"node\">\n<title>Action\n 140721994062480</title>\n<path fill=\"#7890ac\" stroke=\"#7890ac\" d=\"M460.43,-136C460.43,-136 419.35,-136 419.35,-136 413.35,-136 407.35,-130 407.35,-124 407.35,-124 407.35,-112 407.35,-112 407.35,-106 413.35,-100 419.35,-100 419.35,-100 460.43,-100 460.43,-100 466.43,-100 472.43,-106 472.43,-112 472.43,-112 472.43,-124 472.43,-124 472.43,-130 466.43,-136 460.43,-136\"/>\n<text text-anchor=\"middle\" x=\"439.89\" y=\"-115.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">yes1_node1</text>\n</g>\n<!-- Action\n 140721992893968&#45;&gt;Action\n 140721994062480 -->\n<g id=\"edge4\" class=\"edge\">\n<title>Action\n 140721992893968&#45;&gt;Action\n 140721994062480</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M265.83,-118C265.83,-118 402.2,-118 402.2,-118\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"402.2,-119.75 407.2,-118 402.2,-116.25 402.2,-119.75\"/>\n</g>\n<!-- Decision\n 140721994060304 -->\n<g id=\"node6\" class=\"node\">\n<title>Decision\n 140721994060304</title>\n<polygon fill=\"#7890ac\" stroke=\"#7890ac\" points=\"346.03,-82 302.85,-64 346.03,-46 389.21,-64 346.03,-82\"/>\n<text text-anchor=\"middle\" x=\"346.03\" y=\"-61.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">decision2</text>\n</g>\n<!-- Action\n 140721992893392&#45;&gt;Decision\n 140721994060304 -->\n<g id=\"edge5\" class=\"edge\">\n<title>Action\n 140721992893392&#45;&gt;Decision\n 140721994060304</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M265.78,-64C265.78,-64 297.66,-64 297.66,-64\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"297.66,-65.75 302.66,-64 297.66,-62.25 297.66,-65.75\"/>\n</g>\n<!-- Action\n 140721994061072 -->\n<g id=\"node7\" class=\"node\">\n<title>Action\n 140721994061072</title>\n<ellipse fill=\"#7890ac\" stroke=\"#7890ac\" cx=\"599.41\" cy=\"-72\" rx=\"18\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"599.41\" y=\"-69.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">end</text>\n</g>\n<!-- Action\n 140721994062480&#45;&gt;Action\n 140721994061072 -->\n<g id=\"edge6\" class=\"edge\">\n<title>Action\n 140721994062480&#45;&gt;Action\n 140721994061072</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M472.56,-118C519.23,-118 599.41,-118 599.41,-118 599.41,-118 599.41,-95.18 599.41,-95.18\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"601.16,-95.18 599.41,-90.18 597.66,-95.18 601.16,-95.18\"/>\n</g>\n<!-- Action\n 140721994061968 -->\n<g id=\"node8\" class=\"node\">\n<title>Action\n 140721994061968</title>\n<path fill=\"#7890ac\" stroke=\"#7890ac\" d=\"M532.41,-90C532.41,-90 502.41,-90 502.41,-90 496.41,-90 490.41,-84 490.41,-78 490.41,-78 490.41,-66 490.41,-66 490.41,-60 496.41,-54 502.41,-54 502.41,-54 532.41,-54 532.41,-54 538.41,-54 544.41,-60 544.41,-66 544.41,-66 544.41,-78 544.41,-78 544.41,-84 538.41,-90 532.41,-90\"/>\n<text text-anchor=\"middle\" x=\"517.41\" y=\"-69.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">yes2</text>\n</g>\n<!-- Decision\n 140721994060304&#45;&gt;Action\n 140721994061968 -->\n<g id=\"edge7\" class=\"edge\">\n<title>Decision\n 140721994060304&#45;&gt;Action\n 140721994061968</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M379.89,-68C379.89,-68 485.38,-68 485.38,-68\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"485.38,-69.75 490.38,-68 485.38,-66.25 485.38,-69.75\"/>\n<text text-anchor=\"middle\" x=\"439.89\" y=\"-69.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">yes</text>\n</g>\n<!-- Action\n 140721998383376 -->\n<g id=\"node9\" class=\"node\">\n<title>Action\n 140721998383376</title>\n<path fill=\"#7890ac\" stroke=\"#7890ac\" d=\"M532.41,-36C532.41,-36 502.41,-36 502.41,-36 496.41,-36 490.41,-30 490.41,-24 490.41,-24 490.41,-12 490.41,-12 490.41,-6 496.41,0 502.41,0 502.41,0 532.41,0 532.41,0 538.41,0 544.41,-6 544.41,-12 544.41,-12 544.41,-24 544.41,-24 544.41,-30 538.41,-36 532.41,-36\"/>\n<text text-anchor=\"middle\" x=\"517.41\" y=\"-15.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">no2</text>\n</g>\n<!-- Decision\n 140721994060304&#45;&gt;Action\n 140721998383376 -->\n<g id=\"edge8\" class=\"edge\">\n<title>Decision\n 140721994060304&#45;&gt;Action\n 140721998383376</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M355.73,-50C391.99,-50 517.41,-50 517.41,-50 517.41,-50 517.41,-41.24 517.41,-41.24\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"519.16,-41.24 517.41,-36.24 515.66,-41.24 519.16,-41.24\"/>\n<text text-anchor=\"middle\" x=\"439.89\" y=\"-28.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"9.00\">no</text>\n</g>\n<!-- Action\n 140721994061968&#45;&gt;Action\n 140721994061072 -->\n<g id=\"edge9\" class=\"edge\">\n<title>Action\n 140721994061968&#45;&gt;Action\n 140721994061072</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M544.72,-72C544.72,-72 576.01,-72 576.01,-72\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"576.01,-73.75 581.01,-72 576.01,-70.25 576.01,-73.75\"/>\n</g>\n<!-- Action\n 140721998383376&#45;&gt;Action\n 140721994061072 -->\n<g id=\"edge10\" class=\"edge\">\n<title>Action\n 140721998383376&#45;&gt;Action\n 140721994061072</title>\n<path fill=\"none\" stroke=\"#607894\" d=\"M544.72,-18C568.57,-18 599.41,-18 599.41,-18 599.41,-18 599.41,-48.72 599.41,-48.72\"/>\n<polygon fill=\"#607894\" stroke=\"#607894\" points=\"597.66,-48.72 599.41,-53.72 601.16,-48.72 597.66,-48.72\"/>\n</g>\n</g>\n</svg>\n",
      "text/plain": [
       "<h1st.core.viz.DotGraphVisualizer at 0x7ffc64b9c890>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "g = h1.Graph()\n",
    "g.start()\n",
    "yes1, no1 = g.add(h1.Decision(h1.Model(), id='decision1'))\\\n",
    "    .add(yes=h1.Action(h1.Model(), id='yes1'), no=h1.Action(h1.Model(), id='no1'))\n",
    "\n",
    "yes1.add(h1.Model(), id='yes1_node1')\n",
    "no1.add(h1.Decision(h1.Model(), id='decision2'))\\\n",
    "    .add(yes=h1.Action(h1.Model(), id='yes2'), no=h1.Action(h1.Model(), id='no2'))\n",
    "\n",
    "g.end()\n",
    "\n",
    "g.visualize()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".env",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.8 (main, Oct 13 2022, 09:48:40) [Clang 14.0.0 (clang-1400.0.29.102)]"
  },
  "orig_nbformat": 2,
  "vscode": {
   "interpreter": {
    "hash": "80f45559c1061daf39fd916c111bc338b6845426a849ed7333940eac956c3a77"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
